package com.gong.gongcloudpicture1.exception;

public class ThrowUtils {


    /**
     * 第一次层封装
     * @param condition
     * @param runtimeException
     */
    public static void throwIf(boolean condition, RuntimeException runtimeException) {
        if (condition) {
            throw runtimeException;
        }
    }


    /**
     * 第一次层封装
     * @param condition
     * @param businessException
     */
    public static void throwIf(boolean condition, BusinessException businessException) {
        if (condition) {
            throw businessException;
        }
    }


    /**
     * 条件成立抛异常
     *
     * @param condition 条件
     * @param errorCode
     */
    public static void throwIf(boolean condition, ErrorCode errorCode) {
        throwIf(condition, new BusinessException(errorCode));
    }


    /**
     * 条件成立抛异常
     * @param condition
     * @param errorCode
     * @param message 自定义信息
     */
    public static void throwIf(boolean condition, ErrorCode errorCode, String message) {
        throwIf(condition, new BusinessException(errorCode, message));
    }




}
